package com.funtl.apache.dubbo.log.controller;

import com.funtl.apache.dubbo.log.dto.OrderLogDto;
import com.funtl.apache.dubbo.log.mq.producer.OrderProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/log")
public class LogController {

    @Autowired
    private OrderProducer orderProducer;

    @GetMapping("/create")
    public String insert(@RequestParam(name = "order_id") Integer orderId,
                         @RequestParam(name = "order_item_id") Integer orderItemId) {
        OrderLogDto logDto = new OrderLogDto();
        logDto.setOrderId(orderId);
        logDto.setOrderItemId(orderItemId);
        orderProducer.product(logDto);
        return "success";
    }
}
